//improvement: O(steps^2) -> O(steps);otherwise it can only price within 10000 steps

#ifndef BINOMIAL_TREE_H
#define BINOMIAL_TREE_H

#include <vector>
#include "Parameter.h"
#include "SolvableTree.h"

class BinomialTree
{
public:
	BinomialTree(double spot, const Parameter& r, const Parameter& vol,
		double time, long steps);
	double calcPrice(const SolvableTree& product);
	double calcGreek(const SolvableTree& product);
protected:
	void buildTree();
private:
	double m_spot;
	Parameter m_r;
	Parameter m_vol;
	long m_steps;
	double m_time;
	bool m_treebuilt;

	std::vector<std::vector<std::pair<double,double> > > m_tree;
	std::vector<double> m_discounts;
};

#endif